<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;

class KongSaiEnController extends Controller
{
    private $baseUrl = "";  

    //如果希望多台面板，可以在实例化对象时，将面板地址与密钥传入
    public function __construct($ip='192.168.8.114',$port='9001'){
        $this->baseUrl = "http://{$ip}:{$port}";
        // $this->baseUrl = "http://{$ip}";
    }

    //地址可用性测试
    public function test(){
        $url = $this->baseUrl."/app/TestConnect?id=1";
        // dd($url);
        return curl($url,'',['Content-Type: application/json']);
    }

    //登录
    public function login(){
        $url = $this->baseUrl."/app/Login";
        $params = [
            'loginName'=>'master',
            'password'=>'master',
        ];
        $params = json_encode($params);
        // dd($url);
        return curl($url,$params);
    }

}
